<template>
    <template v-for="item in children" :key="item.id">
            <!-- 没有子菜单就是菜单项 -->
            <el-sub-menu v-if="item.children" :index="item.path">
                <template #title>                    
                    <span>{{item.name}}</span>
                </template>  
                <!-- 形成了递归嵌套 -->
                <SubMenu :children="item.children"></SubMenu>          
            </el-sub-menu>
            <el-menu-item :index="item.path" v-else>
            <span>{{item.name}}</span>
            </el-menu-item>
    </template>
</template>
<script>
export default {
    // 默认有子选项children 默认值是[]
    props:{
        children:{type:Array,default:()=>[]}
    }
}
</script>